<template>
  <footer class="footer">
    <span class="todo-count">剩余 <strong>{{num}}</strong></span>
    <ul class="filters">
      <li>
        <a :class="{selected:task === 'all' }" 
        href="javascript:;" 
        @click.prevent="$emit('changeTask','all')">全部</a>
      </li>
      <li>
        <a href="javascript:;"
        :class="{selected:task === 'no'}"
        @click.prevent="$emit('changeTask','no')">未完成</a>
      </li>
      <li>
        <a href="javascript:;"
        :class="{selected:task === 'yes'}"
        @click.prevent="$emit('changeTask','yes')">已完成</a>
      </li>
    </ul>
    <button class="clear-completed" v-if="isShow" @click="clearFun">清除已完成</button>
  </footer>
</template>

<script>
export default {
  props:{
    list:{
      type:Array,
      require: true
    },
    task: String,
  },
  methods:{
    clearFun(){
      this.$emit('clear')
    }
  },
  computed:{
    num(){
      return this.list.filter(item => !item.isDone).length
    },
     isShow(){
      return this.list.some((item) => item.isDone)
    }
  }

}
</script>